package com.insta.monopoly.cases;

import java.util.ArrayList;
import java.util.Collections;

import com.insta.monopoly.jeu.Tools;

public class Case {
	private int position;
	private String nom;
	
	public Case(int position, String nom) {
		this.position = position;
		this.nom = nom;
	}

	public int getPosition() {
		return position;
	}

	public void setPosition(int position) {
		this.position = position;
	}

	public String getNom() {
		return this.nom;
	}

	public void setNom(String nom) {
		this.nom = nom;
	}
	
	@Override
	public String toString() {
		return "Case [position=" + position + ", nom=" + nom + "]";
	}
	
	public boolean estUneCaseCommerciale() {
		if(this.estUneRue() || this.estLaCompagnieDesEaux() || this.estLaCompagnieElectricite() || this.estUneGare()) {
			return true;
		} else {
			return false;
		}
	}

	public boolean estUneRue() {
		ArrayList<Integer> positionRues = new ArrayList<Integer>();
		Integer[] listeRues = new Integer[] { 1, 3, 6, 8, 9, 11, 13, 14, 16,
				18, 19, 21, 23, 24, 26, 27, 29, 31, 32, 34, 37, 39 };
		Collections.addAll(positionRues, listeRues);
		if (Tools.in_array(this.position, positionRues)) {
			return true;
		}
		return false;
	}

	public boolean estUneTaxe() {
		ArrayList<Integer> positionTaxes = new ArrayList<Integer>();
		Integer[] listeTaxes = new Integer[] { 4, 38 };
		Collections.addAll(positionTaxes, listeTaxes);
		if (Tools.in_array(this.position, positionTaxes)) {
			return true;
		}
		return false;
	}

	public boolean estLaCompagnieElectricite() {
		ArrayList<Integer> positionCompagnies = new ArrayList<Integer>();
		Integer[] listeCompagnies = new Integer[] { 12 };
		Collections.addAll(positionCompagnies, listeCompagnies);
		if (Tools.in_array(this.position, positionCompagnies)) {
			return true;
		}
		return false;
	}
	
	public boolean estLaCompagnieDesEaux() {
		ArrayList<Integer> positionCompagnies = new ArrayList<Integer>();
		Integer[] listeCompagnies = new Integer[] { 28 };
		Collections.addAll(positionCompagnies, listeCompagnies);
		if (Tools.in_array(this.position, positionCompagnies)) {
			return true;
		}
		return false;
	}
	


	
	public boolean estUneCarte() {
		ArrayList<Integer> positionCartes = new ArrayList<Integer>();
		Integer[] listeCartes = new Integer[] { 2, 7, 17, 22, 33, 36 };
		Collections.addAll(positionCartes, listeCartes);
		if (Tools.in_array(this.position, positionCartes)) {
			return true;
		}
		return false;
	}
	
	public boolean estUneCarteChance() {
		ArrayList<Integer> positionCartesChance = new ArrayList<Integer>();
		Integer[] listeCartes = new Integer[] { 7, 22, 36 };
		Collections.addAll(positionCartesChance, listeCartes);
		if (Tools.in_array(this.position, positionCartesChance)) {
			return true;
		}
		return false;
	}
	
	public boolean estUneCarteCommunaute() {
		ArrayList<Integer> positionCartesCommunaute = new ArrayList<Integer>();
		Integer[] listeCartes = new Integer[] { 2, 17, 33 };
		Collections.addAll(positionCartesCommunaute, listeCartes);
		if (Tools.in_array(this.position, positionCartesCommunaute)) {
			return true;
		}
		return false;
	}

	public boolean estUneGare() {
		ArrayList<Integer> positionGares = new ArrayList<Integer>();
		Integer[] listeGares = new Integer[] { 5, 15, 25, 35 };
		Collections.addAll(positionGares, listeGares);
		if (Tools.in_array(this.position, positionGares)) {
			return true;
		}
		return false;
	}
	
	public boolean estUnePrison() {
		if (this.position == 10) {
			return true;
		}
		return false;
	}
	
	public boolean estUnParc() {
		if (this.position == 20) {
			return true;
		}
		return false;
	}
	
	public boolean estUneCaseAllerEnPrison() {
		if (this.position == 30) {
			return true;
		}
		return false;
	}
	
	public boolean estSituee(String location) {
		if(this.getPosition() <= 10 && location == "BOTTOM") {
			return true;
		} else if(this.getPosition() > 10 && this.getPosition() <= 20 && location == "LEFT") {
			return true;
		} else if(this.getPosition() > 20 && this.getPosition() <= 30 && location == "TOP") {
			return true;
		} else if(this.getPosition() > 30 && this.getPosition() <= 40 && location == "RIGHT") {
			return true;
		}
		return false;
	}
	
	public int estSitueeInt() {
		if(this.getPosition() <= 10) {
			return 0;
		} else if(this.getPosition() > 10 && this.getPosition() <= 20) {
			return 1;
		} else if(this.getPosition() > 20 && this.getPosition() <= 30) {
			return 2;
		} else if(this.getPosition() > 30 && this.getPosition() <= 40 ) {
			return 3;
		}
		return 0;
	}
}
